
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;

/* Start of 'Group' class */
public class Group extends MIDlet implements CommandListener
{
  private Command exitCommand;
  private Form form;
  private static String Out = "Leader: Burkov Edward, 11-3";

  /* Start MIDlet
   * ARGUMENTS: None.
   * RETURNS: None.
   */
  public void startMIDlet()
  {
    switchDisplayable(null, getForm());
  } /* End of 'startMIDlet' function */


  /* Switches a current displayable in a display.
   * ARGUMENTS:
   *  - the Alert which is temporarily set to the display( if null, then next Displayable is set immediately)
   *      Alert alert;
   *  - the Displayable to be set
   *      Displayable nextDisplayable;
   * RETURNS: None.
   */
  public void switchDisplayable(Alert alert, Displayable nextDisplayable)
  {
    Display display = getDisplay();

    if (alert == null)
      display.setCurrent(nextDisplayable);
    else
      display.setCurrent(alert, nextDisplayable);
  } /* End of 'switchDisplayable' function */


  /* Indicate that command has been invoked on a particular displayable.
   * ARGUMENTS:
   *  - the Command that was invoked
   *      Command command;
   *  - the Displayable where the command was invoked
   *      Displayable displayable;
   * RETURNS: None.
   */
  public void commandAction(Command command, Displayable displayable)
  {
    if (displayable == form)
      if (command == exitCommand)
        exitMIDlet();
  } /* End of 'commandAction' function */


  /* Get an initiliazed instance of exitCommand component.
   * ARGUMENTS: None.
   * RETURNS:
   *  - the initialized component instance
   *      exitCommand;
   */
  public Command getExitCommand()
  {
    if (exitCommand == null)
      exitCommand = new Command("Exit", Command.EXIT, 0);
    return exitCommand;
  } /* End of 'getExitCommand' function */


  /* Get an initiliazed instance of form component.
   * ARGUMENTS: None.
   * RETURNS:
   *  - the initialized component instance
   *      form;
   */
  public Form getForm( )
  {
    if (form == null)
    {
      form = new Form("Group #6", null );
      Ticker Tick = new Ticker(Out);
      form.setTicker(Tick);
      form.addCommand(getExitCommand());
      form.setCommandListener(this);
    }
    return form;
  } /* End of 'getForm' function */



  /* Get a display instance.
   * ARGUMENTS: None.
   * RETURNS:
   *  - the display instance
   *      Display;
   */
  public Display getDisplay ()
  {
    return Display.getDisplay(this);
  } /* End of 'getDisplay' function */


  /* Start application function
   * ARGUMENTS: None.
   * RETURNS: None.
   */
  public void startApp( )
  {
    startMIDlet();
  } /* End of 'startApp' function */


  /* Pause application function
   * ARGUMENTS: None.
   * RETURNS: None.
   */
  public void pauseApp( )
  {
  } /* End of 'pauseApp' function */


   /* Exits MIDlet.
   * ARGUMENTS: None.
   * RETURNS: None.
   */
  public void exitMIDlet()
  {
    switchDisplayable (null, null);
    destroyApp(true);
    notifyDestroyed();
  } /* End of 'exitMIDlet' function */


   /* Destroy application function
   * ARGUMENTS:
   *   - unconditional exit flag
   *       boolean unconditional;
   * RETURNS: None.
   */
  public void destroyApp( boolean unconditional )
  {
  } /* End of 'destroyApp' function */


} /* End of 'Group' class */
